﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="register_modify.aspx.cs" Inherits="WebSite.cn.register_modify" %>
<%@ Register Src="head.ascx" TagName="head" TagPrefix="uc1" %>
<%@ Register Src="bottom.ascx" TagName="bottom" TagPrefix="uc3" %>
<%@ Register src="../Controls/userLeftMenu.ascx" tagname="userLeftMenu" tagprefix="uc6" %>
   
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title><%=WebSite.info.info1("", "shoptitle")%></title>
    <meta name="Description" content="<%=WebSite.info.info1("","shopcontent")%>" /> 
    <meta name="Keywords" content="<%=WebSite.info.info1("","shopkey")%>" />
<link href="/cn/css/member.css" type="text/css" rel="stylesheet" />
<link href="/cn/css/idialog.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="/js/artDialog.js"></script>
<script type="text/javascript" src="/js/iframeTools.source.js"></script>
<script type="text/javascript" src="/js/art_dialog.js"></script>

   
</head>

<body class="login">

   <form id="form1" runat="server">
	<uc1:head ID="head_1" runat="server" />
   
          <center>

<div class="container">
 <img src="/uploadfile/banner/k09900.jpg" width="1028px" />
 	  <div class="page_navigater">
			<p><a href="/cn/index.html">首页</a>><a href="/cn/userinfo.html">我的福袋</a> >资料修改</p>
	  </div>

  <div style="float:left;">
    <uc6:userLeftMenu ID="userLeftMenu1" runat="server" />
   </div>
    <div id="register" style="width:760px; float:right; text-align:left;">
<h2><strong>资料修改</strong></h2>

<p><label for="txtUserName">用户名</label><input id="txtUserName" runat="server" type="text" onpaste="return false" style="ime-mode: disabled" onkeydown="if(event.keyCode==13)event.keyCode=9"/><span id="spUserName">*4～16个字符,包括数字、英文字母、下划线</span></p>
<p><label for="txtOldPwd">旧密码</label><input id="txtOldPwd" runat="server" type="password" /><span id="spOldPwd"></span></p>
<p><label for="txtUserPwd">新密码</label><input id="txtUserPwd" runat="server" type="password" /><span id="spPwd">6～16个字符,包括数字、英文字母、任意字符</span></p>
<p><label for="txtAgainPwd">确认密码</label><input id="txtAgainPwd" runat="server" type="password" /><span id="spAgPwd"></span></p>
<p><label for="txtName">真实姓名</label><input id="txtName" runat="server" type="text" /><span id="spName">*</span></p>
<p><label for="txtMobile">手机</label><input id="txtMobile" runat="server" type="text" /><span id="spMobile">*手机与电话必须要填一项</span></p>
<p><label for="txtTel">电话</label><input id="txtTel"  runat="server" type="text" /><span id="spTel">*</span></p>
<p><label for="txtAddress">地址</label><input id="txtAddress" runat="server" type="text" /><span id="spAddress">*</span></p>
<p><label for="txtEmail">电子邮箱</label><input id="txtEmail" runat="server" type="text" /><span id="spEmail">*</span></p>
<asp:Button ID="btnInfoUpdate" runat="server" CssClass="submit" Text="确认修改" 
            />
            <input type="hidden" id="hdId" runat="server" value="" />
      <input type="hidden" id="hdUserName" runat="server" value="" />
       <input type="hidden" id="hdEmail" runat="server" value="" />



</div>

</div>
</center>
</form>
</body>
</html>


<script type="text/javascript">

    $(function () {
        $("#txtUserName").blur(function () {
            if ($("#txtUserName").val() == "") {
                $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 请输入用户名！");
            }
            else {
                if ($("#txtUserName").val().length < 4 || $("#txtUserName").val().length > 16)
                    $("#spUserName").html("<img src=\"/cn/images/wrong.gif\" /> 用户名长度不符！");
                else $("#spUserName").html("<img src=\"/cn/images/right.gif\"/>");
            }
            return false;
        });

        $("#txtName").blur(function () {
            if ($("#txtName").val() == "") {
                $("#spName").html("<img src=\"/cn/images/wrong.gif\" /> 请输入真实姓名！");
            }
            return false;
        });
  
        $("#txtEmail").blur(function () {
            if ($("#txtEmail").val() == "") $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 请输入电子邮箱！");
            else {
                if ($("#txtEmail").val().match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == null)
                    $("#spEmail").html("<img src=\"/cn/images/wrong.gif\" /> 电子邮箱格式不符！");
                else $("#spEmail").html("<img src=\"/cn/images/right.gif\"/>");
            }
            return false;
        });


    });


    $( "#btnInfoUpdate" ).click( function () {


        ///用户名
        if ( $( "#txtUserName" ).val() == "" ) {
            $( "#txtUserName" ).select();
            $( "#spUserName" ).html( "<img src=\"/cn/images/wrong.gif\" /> 请输入用户名！" );
            return false;
        }
        else {
            if ( $( "#txtUserName" ).val().length < 4 || $( "#txtUserName" ).val().length > 16 ) {
                $( "#txtUserName" ).select();
                $( "#spUserName" ).html( "<img src=\"/cn/images/wrong.gif\" /> 用户名长度不符！" );
                return false;
            } else $( "#spUserName" ).html( "<img src=\"/cn/images/right.gif\"/>" );
        }

        if ( $( "#txtName" ).val() == "" ) {
            $( "#txtName" ).select();
            $( "#spName" ).html( "<img src=\"/cn/images/wrong.gif\" /> 请输入真实姓名！" );
            return false;
        }


        if ( $( "#txtOldPwd" ).val() != "" ) {

            if ( $( "#txtUserPwd" ).val().length < 6 || $( "#txtUserPwd" ).val().length > 16 ) {
                $( "#txtUserPwd" ).select();
                $( "#spPwd" ).html( "<img src=\"/cn/images/wrong.gif\" /> 密码长度不符，必须在6-16个字符之间！" );
                return false;
            } else $( "#spPwd" ).html( "<img src=\"/cn/images/right.gif\"/>" );

            if ( $( "#txtAgainPwd" ).val() != $( "#txtUserPwd" ).val() ) {
                $( "#txtAgainPwd" ).select();
                $( "#spAgPwd" ).html( "<img src=\"/cn/images/wrong.gif\" /> 确认密码不一致！" );
                return false;
            } else $( "#spAgPwd" ).html( "<img src=\"/cn/images/right.gif\"/>" );
        }
        ///Email
        if ( $( "#txtEmail" ).val() == "" ) {
            $( "#txtEmail" ).select();
            $( "#spEmail" ).html( "<img src=\"/cn/images/wrong.gif\" /> 请输入电子邮箱！" );
            return false;
        } else {
            if ( $( "#txtEmail" ).val().match( /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/ ) == null ) {
                $( "#txtEmail" ).select();
                $( "#spEmail" ).html( "<img src=\"/cn/images/wrong.gif\" /> 电子邮箱格式不符！" );
                return false;
            } else $( "#spEmail" ).html( "<img src=\"/cn/images/right.gif\"/>" );
        }

        if ( $( "#txtMobile" ).val() == "" && $( "#txtTel" ).val() == "" ) {
            $( "#txtMobile" ).select();
            $( "#spTel" ).html( "<img src=\"/cn/images/wrong.gif\" /> 手机与电话必须要填一项！" );
            return false;
        }
        if ( $( "#txtAddress" ).val() == "" ) {
            $( "#txtAddress" ).select();
            $( "#spAddress" ).html( "<img src=\"/cn/images/wrong.gif\" /> 请输入地址！" );
            return false;
        }

    
        $.ajax( {
            type: "POST",
            url: "/registerUpdateHandler.ashx",
            data: "id=" + escape( $( "#hdId" ).val() )
            + "&userName=" + escape( $( "#txtUserName" ).val() ) + "&name=" + escape( $( "#txtName" ).val() )
             + "&address=" + escape( $( "#txtAddress" ).val() )
             + "&email=" + escape( $( "#txtEmail" ).val() )
             + "&mobile=" + escape( $( "#txtMobile" ).val() )
             + "&tel=" + escape( $( "#txtTel" ).val() )
             + "&oldUserName=" + escape( $( "#hdUserName" ).val() )
             + "&oldPassword=" + escape( $( "#txtOldPwd" ).val() )
             + "&oldEmail=" + escape( $( "#hdEmail" ).val() )
             + "&userPwd=" + escape( $( "#txtUserPwd" ).val() ) + "&code=" + escape( $( "#txtCode" ).val() ),
            success: function ( msg ) {
                if ( msg == "2" ) {
                    $( "#txtUserName" ).select();
                    $( "#spUserName" ).html( "<img src=\"/cn/images/wrong.gif\" /> 新用户名已被使用！" );
                }
                else if ( msg == "3" ) {
                    $( "#txtEmail" ).select();
                    $( "#spEmail" ).html( "<img src=\"/cn/images/wrong.gif\" /> 新电子邮箱已被注册！" );
                    $( "#txtEmail" ).select();
                }
                else if ( msg == "4" ) {
                    $( "#txtOldPwd" ).select();
                    $( "#spOldPwd" ).html( "<img src=\"/cn/images/wrong.gif\" /> 旧密码不正确，请重新输入！" );
                    $( "#txtOldPwd" ).select();
                }
                else if ( msg == "5" ) {

                    art.dialog.tips( "很抱歉，更新失败！", 1.5 );
                }
                else if ( msg == "1" ) {
                    art.dialog.tips( "恭喜您，资料更新成功！", 3 );
                    setTimeout( "parent.location.reload()", 2000 );

                }
            }
        } );
        return false;
    } );


</script>
